//
//  RFABrowserCell.m
//  RFA Manager
//
//  Created by Torsten Kammer on 25.02.08.
//  Copyright 2008 Ferroequinologist.de. All rights reserved.
//

#import "RFABrowserCell.h"
#import "RFATreeNode.h"

@implementation RFABrowserCell

- (id)copyWithZone:(NSZone *)zone
{
    RFABrowserCell *result = [super copyWithZone:zone];
    result->node = nil;
    result.objectValue = node;
    return result;
}

- (void)setObjectValue:(id)anObject;
{
	if (anObject && ![anObject isKindOfClass:[NSString class]])
	{ 
        node = anObject;
        if (node.isLeaf) self.image = [[NSWorkspace sharedWorkspace] iconForFileType:node.name.pathExtension];
        //TODO: Replace this ugly hack for folder icon.
        else self.image = [[NSWorkspace sharedWorkspace] iconForFile:@"/System/Library"];
        
        // Apples documentation is inconsistent. It says that the image set for the cell does not
        // get scaled, but it also has setImageScaling. I prefer to stay on the safe side here.
        self.image.size = NSMakeSize(16.0f, 16.0f);
        
		[super setStringValue:node.name];
	}
    else [super setObjectValue:anObject];
}

- (id)objectValue
{
    return node;
}

@end
